-- stack: in -- format: 8 (HyperCard 1) -- flags: 0x1000 (none) -- protect password hash: 0 -- maximum user level: 5 (scripting) -- window: Rect(x1=0, y1=0, x2=0, y2=0) -- screen: Rect(x1=0, y1=0, x2=0, y2=0) -- card dimensions: w=0 h=0 -- scroll: x=0 y=0 -- background count: 17 -- first background id: 2748 -- card count: 33 -- first card id: 3057 -- list block id: 6551 -- print block id: 0 -- font table block id: 0 -- style table block id: 0 -- free block count: 3 -- free size: 8672 bytes -- total size: 172032 bytes -- stack block size: 27648 bytes -- created by hypercard version: 0x01208000 -- compacted by hypercard version: 0x01208000 -- modified by hypercard version: 0x01208000 -- opened by hypercard version: 0x01208000 -- patterns[0]: 0x0000000000000000 -- patterns[1]: 0x8000000008000000 -- patterns[2]: 0x8800220088002200 -- patterns[3]: 0x8888222288882222 -- patterns[4]: 0x88AA22AA88AA22AA -- patterns[5]: 0xCCAA33AACCAA33AA -- patterns[6]: 0xEEAABBAAEEAABBAA -- patterns[7]: 0xEEBBBBEEEEBBBBEE -- patterns[8]: 0xFFBBFFEEFFBBFFEE -- patterns[9]: 0xFFBBFFFFFFBBFFFF -- patterns[10]: 0x8010022001084004 -- patterns[11]: 0xFFFFFFFFFFFFFFFF -- patterns[12]: 0x8822882288228822 -- patterns[13]: 0x1122448811224488 -- patterns[14]: 0xC4800C6843023026 -- patterns[15]: 0xB130031BD8C00C8D -- patterns[16]: 0xAA00AA00AA00AA00 -- patterns[17]: 0x8822552288225522 -- patterns[18]: 0x8855225588552255 -- patterns[19]: 0x77DD77DD77DD77DD -- patterns[20]: 0x8000000000000000 -- patterns[21]: 0xAA55AA55AA55AA55 -- patterns[22]: 0x038448300C020101 -- patterns[23]: 0x8244394482010101 -- patterns[24]: 0x8814224188412214 -- patterns[25]: 0x8080413E080814E3 -- patterns[26]: 0x22048C7422179810 -- patterns[27]: 0xBE808808EB088880 -- patterns[28]: 0x25C8328964244C92 -- patterns[29]: 0xA29C41BE2AC914EB -- patterns[30]: 0x40A00000040A0000 -- patterns[31]: 0x8040200002040800 -- patterns[32]: 0xAA00800088008000 -- patterns[33]: 0xFF80808080808080 -- patterns[34]: 0x081C22C180010204 -- patterns[35]: 0xFF808080FF080808 -- patterns[36]: 0xF87422478F172271 -- patterns[37]: 0xBF00BFBFB0B0B0B0 -- patterns[38]: 0xFF7FBE5DA2418000 -- patterns[39]: 0xFAF5FAF5A050A050 -- checksum: 0x0 ----- HyperTalk script ----- -- Some global vars -- -- dupList: a return-separated list of the keys of duplicated cards -- dupCard: a comma-separated list of card numbers of the corresponding -- keys in dupList. -- searchField: the id of the field last used in a search. -- searchString: the string last used in a search. -- on openstack -- cardList: a return-separated list of bibliography backgrounds -- dupList is the list of duplicate keys. -- fieldList: a comma-separated list of the fields on bibliogrpahy -- cards. It is used to get field indexes for the find commands. -- findList is the menu for fields to search. -- journalList: a return-separated list of journals. -- monthList: a return-separated list of months. -- readStatusList: a comma-separated list of possible entries in the -- "Read Status" field. -- yearList: a returns-separated list of the past 5 years (descending). -- firstRefCard is the first card containing references. -- recentCard is global cardList, dupList, fieldList, findList, journalList global readStatusList, monthList, yearList global firstRefCard, recentCard, termChar show menubar hide message box -- cardList put "Article"&return&"Book"&return&"Booklet"&return&"In Book"&return& "In Collection"&return&"In Proceedings"&return&"Manual"&return& "Masters Thesis"&return&"Misc."&return&"Ph.d Thesis"&return& "Proceedings"&return&"Tech Report"&return&"Unpublished"into cardList -- dupList put "No Duplicates" into dupList -- fieldList put "Card Type,Read Status,Key,"& "Author,Title,Journal,"& "Book Title,Month,Year,Chapter,"& "Pages,Editor,Organization,"& "Publisher,How Published,Address,"& "Volume,Series,Edition,Type,"& "Number,Bibliogrpahy Note,Notes,"& "Key Words,Location" into fieldList -- journalList set lockScreen to true push card go to card "Journal Names" --put line 1 of field "Names" into journalList --put the number of lines of field "Names" into numLines --repeat with linenr = 2 to numLines -- put journalList & return & line linenr of field "Names" into journalList --end repeat pop card -- monthList put "January"&return&"February"&return&"March"&return&"April"&return& "May"&return&"June"&return&"July"&return&"August"&return&"September"& return&"October"&return&"November"&return&"December" into monthList -- readStatusList put "Read & Filed,Read & Returned,Filed & Not Read,Find It" into readStatusList -- yearList put fourth word of the abbreviated date into year put year into yearList repeat 5 times put year-1 into year put yearList & return & year into yearList end repeat -- findList. This list is made last so it can include other lists. put "Repeat Search"&return&"Key"&return&"Author"&return&"Title"&return& "Read Status,"&readStatusList&return& "Notes"&return&"Key Words"&return&"Organization"&return& "All Fields"&return&"Pick Field...,"&fieldList into findList -- firstRefCard put (number of first card of bkgnd "CardBeforeBibEntries")+1 into firstRefCard put 1 into recentCard -- used in install and delete buttons --go to first card of bkgnd "Article" end openstack on closestack visual effect iris close get the freeSize of this stack if it > 1024*10 then put "Compacting stack..." doMenu Compact Stack put empty hide message end if end closestack on goToCard global cardList put the rect of the target into tempRect put item 1 of HPopupMenu(cardList,0,item 4 of tempRect-1, (item 1 of tempRect)+1) into cardNumber if cardNumber < 1 then exit goToCard put line cardNumber of cardList into bkgndName go to background bkgndName end goToCard on findCard -- used to find a card global findList, readStatusList, searchField, searchString put the rect of the target into tempRect put HPopUpMenu (findList, 0,item 4 of tempRect-1, (item 1 of tempRect)+1) into itemNumber if itemNumber = 0 then exit findCard put line item 1 of itemNumber of findList into fieldName -- If a hierarchical item was picked, the field name include all -- the hierarchical menu, too. Get rid of it. if "," is in fieldName put item 1 of fieldName into fieldName put item 2 of itemNumber into subNum if fieldName is not "Repeat Last" then -- tempID holds the id of the field to look in. 0 means everywhere. if fieldName is "Pick Field ..." then put subNum into tempID else if fieldName is "All Fields" then put 0 into tempID else put fieldNumber(fieldName) into tempID end if if "Read Status" is in fieldName then put item subNum of readStatusList into searchString else ask "Search for:" with searchString if it is empty then exit findCard else put it into searchString end if -- record field and string information. put tempID into searchField end if if searchField is 0 then -- Set up the message box so all the user need do is hit return. put "find " & searchString hide message find searchString else -- Set up the message box so all the user need do is hit return. put "find " & searchString & " in field " & searchField find searchString in field searchField hide message end if end findCard on findSelection if the locktext of the target is true then --unlock the field if set locktext of target to false --it is locked. end if put the optionKey into optStatus put the commandKey into cmdStatus if optStatus is down then put fieldNumber("Key Words") into tempID else if cmdStatus is down then put fieldNumber("Key") into tempID else exit findSelection end if if selection is not empty then --something was selected put selection into SelectedWord if space is in SelectedWord then --the user selected more than 1 word play "boing" "Cs5" exit findSelection --and exit to wait for another selection end if play "harpsichord" "Ct6" find SelectedWord in field tempID if the result is "not found" then --play "boing" "Cs5" play "PWscream" else put tempID into searchField put SelectedWord into searchString put "find" && quote & SelectedWord & quote && "in field" && SearchField hide message end if end if end findSelection on checkKeys global dupList, dupCards, firstRefCard push card set cursor to 4 set lockScreen to true put "Sorting cards..." sort by field "Key" go to card firstRefCard put empty into prevKey put true into firstDup put 1 into dupCount put "Checking for duplicate keys..." repeat while number of this card <> 1 if background field Key is not empty then if background field Key = prevKey then put dupCount +1 into dupCount put "Found " & dupCount & " duplicates of key " & prevKey else if dupCount > 1 then -- finished string of dups if firstDup then -- handle case of first item in list. put prevKey into dupList put number of this card - dupCount into dupCards put false into firstDup else put dupList & return & prevKey into dupList -- Put in the number of the first dup card. put dupCards & "," & number of this card - dupCount into dupCards end if put 1 into dupCount end if put background field Key into prevKey end if go to next card end repeat -- If no dups, say so. if firstDup then put "There were no duplicate keys." put "No Duplicates" into dupList put 0 into dupCards else put "There were duplicated keys." play "PWscream" end if pop card set lockScreen to false end checkKeys on dupKeys global dupList, dupCards put the rect of the target into tempRect put item 1 of HPopUpMenu(dupList,0,(item 4 of tempRect)-1, (item 1 of tempRect)+1) into dupNumber if dupNumber is 0 then exit dupKeys put item dupNumber of dupCards into goCard if goCard <> 0 then go to card goCard end dupKeys on makeNewCard put bkgnd field "card Type" into type doMenu "New Card" put type into background field "Card Type" put "?" into bkgnd field "Read Status" end makeNewCard on doMonth global monthList put the rect of the target into tempRect put item 1 of HPopupMenu(monthList,0,(item 4 of tempRect)-1, (item 1 of tempRect)+1) into monthNumber if monthNumber < 1 then exit doMonth else put line monthNumber of monthList into background field "Month" end doMonth on doYear global yearList put the rect of the target into tempRect put item 1 of HPopupMenu(yearList,0,(item 4 of tempRect)-1, (item 1 of tempRect)+1) into yearNumber if yearNumber < 1 then exit doYear else put line yearNumber of yearList into background field "Year" end doYear on setReadStatus global readStatusList -- Get the current value of the field so you can check it as correctly. put the short name of the target into statusName if word 1 of the target is "card" then put card field statusName into statusValue else put bkgnd field statusName into statusValue end if put 0 into checkItem repeat with x = 1 to number of items in readStatusList if statusValue is item x of readStatusList then put x into checkItem exit repeat end if end repeat -- Convert the readStatusList to one that is return-separated. put item 1 of readStatusList into statusList repeat with x = 2 to the number of items in readStatusList put statusList & return & item x of readStatusList into statusList end repeat put the rect of the target into tempRect put item 1 of HPopupMenu(statusList,checkItem,(item 2 of tempRect), (item 1 of tempRect)+1) into statusValue if statusValue = 0 then exit setReadStatus else put item statusValue of readStatusList into the target end setReadStatus on makeBib global bibFileName, firstRefCard, requiredEntry, lastReqEntry global termChar -- the character that terminates lines -- (linefeed for unix, return for mac). put "Make .bib for mac"&return&"Make .bib for Unix" into bibList put the rect of the target into tempRect put item 1 of HPopupMenu(bibList,0,(item 4 of tempRect)-1, (item 1 of tempRect)+1) into termChar -- set the termination character. if termChar is 0 then exit makeBib else if termChar is 1 then put return into termChar else put lineFeed into termChar -- Note that if you have created a handler for a new form of -- bibliograpy output, it would be called here. -- See what file name the user asks for put PutFile("Save bib file as:",bibFileName) into temp if temp is empty then exit makeBib end if put temp into bibFileName -- This test for a return error seems useless. I don't know how to -- intercept it. open file bibFileName if the result is not empty then answer "Couldn't open file" with "OK" exit makeBib end if set lockScreen to true set cursor to 4 push card put the number of cards - firstRefCard+1 into totalCardNum go to card firstRefCard-1 repeat with cardCount = 1 to totalCardNum go to next card -- Tell the user how things are going. put "Card " & cardCount & " of " & totalCardNum -- Do what you should for this card type if background field Key is not empty then put true into requiredEntry put false into lastReqEntry if the short name of this background is "Article" then do "ArticleBib" else if the short name of this background is "Book" then do "BookBib" else if the short name of this background is "Booklet" then do "BookletBib" else if the short name of this background is "In Book" then do "InBookBib" else if the short name of this background is "In Collection" then do "InCollectionBib" else if the short name of this background is "In Proceedings" then do "InProceedingsBib" else if the short name of this background is "Manual" then do "ManualBib" else if the short name of this background is "Misc." then do "MiscBib" else if the short name of this background is "Proceedings" then do "ProceedingsBib" else if the short name of this background is "Tech Report" then do "TechReportBib" else if the short name of this background is "Masters Thesis" then do "MSThesisBib" else if the short name of this background is "Ph.d Thesis" then do "PhdThesisBib" else if the short name of this background is "Unpublished" then do "UnpublishedBib" end if end if end repeat pop card set lockScreen to false close file bibFileName hide message -- Save only the file name, not the full path. put LastPathComponent(bibFIleName) into bibFileName end makeBib on DoLine -- make an entry global requiredEntry, lastReqEntry, bibFileName, termChar global lineName, lineField if requiredEntry then write tab & lineName & " = {" & field lineField & "}" to file bibFileName if not lastReqEntry then write "," & termChar to file bibFileName end if else if field lineField is not empty then write "," & termChar & tab & lineName & " = {" & field lineField & "}" to file bibFileName end if end DoLine on AddressLine global lineName, lineField put "address" into lineName put "address" into lineField do "DoLine" end AddressLine on AuthorLine global lineName, lineField put "author" into lineName put "author" into lineField do "DoLine" end AuthorLine on BooktitleLine global lineName, lineField put "booktitle" into lineName put "book title" into lineField do "DoLine" end BooktitleLine on ChapterLine global lineName, lineField put "chapter" into lineName put "chapter" into lineField do "DoLine" end ChapterLine on EditionLine global lineName, lineField put "edition" into lineName put "edition" into lineField do "DoLine" end EditionLine on EditorLine global lineName, lineField put "editor" into lineName put "editor" into lineField do "DoLine" end EditorLine on HowpublishedLine global lineName, lineField put "howpublished" into lineName put "how published" into lineField do "DoLine" end HowpublishedLine on InstitutionLine global lineName, lineField put "institution" into lineName put "organization" into lineField do "DoLine" end InstitutionLine on JournalLine global lineName, lineField put "journal" into lineName put "journal" into lineField do "DoLine" end JournalLine on KeyLine global termChar, bibFileName write "{" & field Key & "," & termChar to file bibFileName end KeyLine on LastLine global termChar, bibFileName write " }" & termChar to file bibFileName end LastLine on MonthLine global lineName, lineField put "month" into lineName put "month" into lineField do "DoLine" end MonthLine on NumberLine global lineName, lineField put "number" into lineName put "number" into lineField do "DoLine" end NumberLine on OrganizationLine global lineName, lineField put "organization" into lineName put "organization" into lineField do "DoLine" end OrganizationLine on PagesLine global lineName, lineField put "pages" into lineName put "pages" into lineField do "DoLine" end PagesLine on PublisherLine global lineName, lineField put "publisher" into lineName put "publisher" into lineField do "DoLine" end PublisherLine on SchoolLine global lineName, lineField put "school" into lineName put "organization" into lineField do "DoLine" end SchoolLine on SeriesLine global lineName, lineField put "series" into lineName put "series" into lineField do "DoLine" end SeriesLine on TitleLine global lineName, lineField put "title" into lineName put "title" into lineField do "DoLine" end TitleLine on TypeLine global lineName, lineField put "type" into lineName put "type" into lineField do "DoLine" end TypeLine on bibliographyNoteLine global lineName, lineField put "note" into lineName put "bibliography Note" into lineField do "DoLine" end bibliographyNoteLine on VolumeLine global lineName, lineField put "volume" into lineName put "volume" into lineField do "DoLine" end VolumeLine on YearLine global lineName, lineField put "year" into lineName put "year" into lineField do "DoLine" end YearLine on ArticleBib global bibFileName, requiredEntry, lastReqEntry write "@Article" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "JournalLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "VolumeLine" do "NumberLine" do "PagesLine" do "MonthLine" do "LastLine" end ArticleBib on BookBib global bibFileName, requiredEntry, lastReqEntry write "@BOOK" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "PublisherLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "VolumeLine" do "SeriesLine" do "AddressLine" do "EditionLine" do "MonthLine" do "LastLine" end BookBib on BookletBib global bibFileName, requiredEntry, lastReqEntry write "@Booklet" to file bibFileName do "KeyLine" put true into lastReqEntry do "TitleLine" put false into requiredEntry do "AuthorLine" do "HowpublishedLine" do "AddressLine" do "MonthLine" do "YearLine" do" LastLine" end BookletBib on InProceedingsBib global requiredEntry, bibFileName, lastReqEntry write "@InProceedings" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "BooktitleLine" put true into lastReqEntry do "YearLIne" put false into requiredEntry do "EditorLine" do "PagesLine" do "OrganizationLine" do "PublisherLine" do "AddressLine" do "MonthLine" do "LastLine" end InProceedingsBib on InBookBib global requiredEntry, bibFileName, lastReqEntry write "@InBook" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLIne" do "PublisherLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "ChapterLine" -- chapter and pages are after the required do "PagesLine" -- entries becuase only one is required. do "VolumeLine" do "SeriesLine" do "AddressLIne" do "EditionLine" do "MonthLIne" do "LastLine" end InBookBib on InCollectionBib global requiredEntry, bibFileName, lastReqEntry write "@InCollection" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLIne" do "BooktitleLine" do "PublisherLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "EditorLIne" do "ChapterLine" do "PagesLine" do "AddressLine" do "MonthLine" do "LastLine" end InCollectionBib on ManualBib global requiredEntry, bibFileName, lastReqEntry write "@Manual" to file bibFileName do "KeyLine" put true into lastReqEntry do "TitleLine" put false into requiredEntry do "AuthorLine" do "OrganizationLine" do "AddressLine" do "EditionLine" do "MonthLine" do "YearLine" do "LastLine" end ManualBib on MiscBib global requiredEntry, lastReqEntry, bibFileName, termChar write "@Misc" to file bibFileName put true into lastReqEntry do "KeyLine" if field author is not empty then do "AuthorLine" put false into requiredEntry end if if field title is not empty then do "TitleLine" put false into requiredEntry end if if field "how published" is not empty then do "HowpublishedLine" put false into requiredEntry end if if field month is not empty then do "MonthLine" put false into requiredEntry end if if field year is not empty then do "YearLine" end if do "LastLine" end MiscBib on ProceedingsBib global requiredEntry, bibFileName, lastReqEntry write "@Proceedings" to file bibFileName do "KeyLine" do "TitleLine" put true into lastReqEntry do "YearLine" put false into RequiredEntry do "EditorLine" do "PublisherLine" do "OrganizationLine" do "AddressLIne" do "MonthLine" do "LastLine" end ProceedingsBib on TechReportBib global requiredEntry, bibFileName, lastReqEntry write "@TechReport" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "InstitutionLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "TypeLine" do "NumberLine" do "AddressLine" do "MonthLine" do "LastLine" end TechReportBib on MSThesisBib -- use phdthesis for both masters and phd theses. I don't know if -- these really should differ when printed. global requiredEntry, bibFileName, lastReqEntry write "@mastersthesis" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "SchoolLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "AddressLine" do "MonthLIne" do "LastLine" end MSThesisBib on PhdThesisBib -- use phdthesis for both masters and phd theses. I don't know if -- these really should differ when printed. global requiredEntry, bibFileName, lastReqEntry write "@phdthesis" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLine" do "SchoolLine" put true into lastReqEntry do "YearLine" put false into requiredEntry do "AddressLine" do "MonthLIne" do "LastLine" end PhdThesisBib on UnpublishedBib global requiredEntry, bibFileName, lastReqEntry write "@Unpublished" to file bibFileName do "KeyLine" do "AuthorLine" do "TitleLIne" put true into lastReqEntry do "bibliographyNoteLine" put false into requiredEntry do "MonthLine" do "YearLine" do "LastLine" end UnpublishedBib -- -- LastPathComponent -- given a file pathname, returns the last -- component i.e. whatever comes after the last colon, if anything. -- From Dewi Williams -- function LastPathComponent name -- scan backwards for the last colon. repeat with i = the length of name down to 1 if character i of name is ":" then exit repeat end repeat if i is 1 then -- Name was of the form ":thing" or "thing". Check for leading -- colon, and adjust if necessary. Done for generality. if first character of name is ":" then put 2 into i end if else add 1 to i -- skip the colon end if -- Name was of the form "Thing:otherthing". Return "otherThing". put empty into lastpath repeat with j = i to the length of name put character j of name after lastpath end repeat return lastpath end LastPathComponent function readField fileName -- this reads from a file until it hits a tab, and returns the field -- without the tab. put "" into temp read from file fileName until tab put it into tempLong put length(tempLong)-1 into tempLen repeat with x = 1 to tempLen put char x of tempLong into char x of temp end repeat return temp end readField function fieldNumber fieldName -- Given a field name, return the number of the field. Return 0 if -- the field name does not exist. global fieldList put the number of items in fieldList into fieldListLen repeat with x = 1 to fieldListLen if item x of fieldList is fieldName then return x end repeat return 0 end fieldNumber on complainSound -- Make a complaining sound. play "PWscream" end complainSound